//
//  HWNewAddressViewController.m
//  HWanGame
//
//  Created by 陈道斌 on 2019/10/21.
//  Copyright © 2019 Chendaobin. All rights reserved.
//

#import "HWNewAddressViewController.h"
#import "HWShouHuoDiZhiCell.h"
#import "HWMorendizhiTableViewCell.h"

@interface HWNewAddressViewController ()<UITableViewDataSource,UITableViewDelegate>
@property(strong,nonatomic) UITableView *mainaTableVie;
@property(strong,nonatomic)UIView *lowerPartView;
@property(strong,nonatomic) NSMutableArray  *dataArr;
@property(strong,nonatomic) NSMutableArray *plaseMutabel;
@property(strong,nonatomic) NSMutableArray *contentMutabelArr;
@property(assign,nonatomic) BOOL  xuanzhongBoor;


@end

@implementation HWNewAddressViewController

-(UITableView *)mainaTableVie {

    if  (_mainaTableVie == nil) {

        _mainaTableVie = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH-44-CF_TabbarSafeBottomMargin) style:UITableViewStylePlain];
        _mainaTableVie.delegate = self;
        _mainaTableVie.dataSource = self;
        _mainaTableVie.separatorStyle = UITableViewCellSeparatorStyleNone;
        
        _mainaTableVie.backgroundColor = [UIColor whiteColor];
        _mainaTableVie.backgroundColor = RGB(241, 242, 244);
        
    }
    return   _mainaTableVie ;

}






- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self addCommonAttributes];
    
    [self setupUI];
}

// 添加常用的属性
- (void)addCommonAttributes {
    
   
    self.xuanzhongBoor = NO;
    self.dataArr = [[NSMutableArray alloc]init];
    [self.dataArr addObject:@"收货人"];
    [self.dataArr addObject:@"手机号"];
    [self.dataArr addObject:@"详细信息"];
    
    self.plaseMutabel = [[NSMutableArray alloc]init];
    [self.plaseMutabel addObject:@"请填写收货人姓名"];
    [self.plaseMutabel addObject:@"请填写收货人手机号"];
    [self.plaseMutabel addObject:@"街道、门牌号等"];
    self.contentMutabelArr = [[NSMutableArray alloc]init];
    [self.contentMutabelArr  addObject:@""];
    [self.contentMutabelArr  addObject:@""];
    [self.contentMutabelArr  addObject:@""];
    
    
    
}




- (void)setupUI {
    
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"我的收获地址";
    [self.view addSubview:self.mainaTableVie];
    [self addLowerPartView];

//    UIPasteboard *pb = [UIPasteboard generalPasteboard];
//    pb.string = @"1111";
//     
    
}





// 添加低部UIview
- (void)addLowerPartView {
    
    self.lowerPartView = [[UIView alloc]initWithFrame:CGRectMake(0, kScreenH-44-CF_TabbarSafeBottomMargin, kScreenW, 44+CF_TabbarSafeBottomMargin)];
    // self.lowerPartView.backgroundColor = [UIColor yellowColor];
    self.lowerPartView.backgroundColor = RGB(241, 242, 244);
    [self.view addSubview:self.lowerPartView];
    
    UIButton *butt  = [UIButton setButtonWithFrame:CGRectMake(15, 4, kScreenW-30, 36) Title:@"保存" Image:nil Font:14 Color:RGB(255, 255, 255) Target:self Selector:@selector(buttonTap)];
    butt.backgroundColor = blueBackgroundBT;
    butt.layer.cornerRadius = 18;
    butt.layer.masksToBounds = YES;
    [self.lowerPartView addSubview:butt];
    

    
    
    
}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return  2;
    
    
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    if (section == 0) {
          return  3;
    }
    return  1;
}



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
    if (indexPath.section == 0) {
        
        
        static NSString *cellID  = @"cellID";
           HWShouHuoDiZhiCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
           if (!cell) {
               cell = [[HWShouHuoDiZhiCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
           }
           
         //  cell.textLabel.text = @"12345";
           
           cell.selectionStyle = UITableViewCellSelectionStyleNone;
           cell.backgroundColor = [UIColor whiteColor];
           cell.nameLabel.text = self.dataArr[indexPath.row];
           
           

           NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:self.plaseMutabel[indexPath.row] attributes:
                    @{NSForegroundColorAttributeName:RGB(153, 153, 153),
                      NSFontAttributeName:[UIFont boldSystemFontOfSize:12]}
                    ];
           cell.nametextField.attributedPlaceholder  = attrString;
           
           cell.nametextField.text = self.contentMutabelArr[indexPath.row];
           
           
           return  cell;
        
    } else {
        
        
        static NSString *cellID  = @"cellID";
        
         HWMorendizhiTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
        if (!cell) {
            cell = [[NSBundle mainBundle]loadNibNamed:@"HWMorendizhiTableViewCell" owner:nil options:nil].lastObject;
            
         }
        [cell.xuanzhongSwitvch setOn: self.xuanzhongBoor ];
        
        return cell;
        
    }
    
   
    
    
}


- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForFooterInSection:(NSInteger)section {

    return  10;

//    UIView *backview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 6)];
//    backview.backgroundColor = RGB(241, 242, 244);
//
//    return backview;

}


- (nullable UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    
        UIView *backview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 10)];
        backview.backgroundColor = RGB(241, 242, 244);
    
        return backview;
    
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
   
    
    return  40;
    
}


#pragma mark ------------- 点击保存按钮

- (void)buttonTap {
    
    DLog(@"保存按钮");
    
    
}



@end
